import { _decorator, Component, Node, v3, tween } from 'cc';
import { Card } from './Card';
import { CardGroupParent } from './CardGroupParent';
import GameAllData from './GameAllData';
const { ccclass, property } = _decorator;
/**
 * 玩家卡组
 */
@ccclass('PlayGroup')
export class PlayGroup extends CardGroupParent {

    start() {

    }

    //位置排序
    PositionSort()
    {
        for (let i = 0; i < this.cards.length; i++) {
            const element = this.cards[i];
            let end=v3(40+25*i,0,0);
            tween(element.node).to(0.5, {position:end})
            .start()

            tween(element.node).delay(0.25).call(()=>{
                element.node.setSiblingIndex(i);
            }).start()
            //element.node.position=end;
            element.isTouch=true;
        }
    }

    //强制选择最强卡牌
    ForceSelect(num:number)
    {
        if (num==2) {
            this.foreCards.push(this.cards[this.cards.length-1]);
            this.cards[this.cards.length-1].InterchangeSelect();
            this.foreCards.push(this.cards[this.cards.length-2]);
            this.cards[this.cards.length-2].InterchangeSelect();
        }else 
        {
            this.foreCards.push(this.cards[this.cards.length-1]);
            this.cards[this.cards.length-1].InterchangeSelect();
        } 
    }



}


